package com.gwq;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.*;

@RunWith(SpringRunner.class)
@SpringBootTest
public class FileTester {

    @Test
    public void test(){
        try {  //C:\Users\29122\Desktop
            String s1  = readTxt(new File("C:\\Users\\29122\\Desktop\\20221109200756.txt"));
            System.out.println(s1);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String readTxt(File file) throws IOException {
        String s = "";
        InputStreamReader in = new InputStreamReader(new FileInputStream(file),"UTF-8");
        BufferedReader br = new BufferedReader(in);
        StringBuffer content = new StringBuffer();
        while ((s=br.readLine())!=null){
            content = content.append(s);
        }
        return content.toString();
    }
}
